
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta charset="UTF-8">
<title>详情信息</title>
<script type="text/javascript" charset="utf-8"
	src="../utf8-jsp/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8"
	src="../utf8-jsp/ueditor.all.min.js">
		</script>
<!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
<!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
<script type="text/javascript" charset="utf-8" src="lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript" src="../js/jquery.js"></script>
<script src="../js/jquery.min.js" type="text/javascript"></script>
<link rel="stylesheet" href="../css/bootstrap.css" />
<link rel="stylesheet" href="../css/bootstrap.min.css" />
<link rel="stylesheet" href="../css/bootstrap-datetimepicker.min.css" />
<link rel="stylesheet" href="../css/main.css" />
<script type="text/javascript" src="../js/bootstrap.js"></script>
<!---配置日期控件-->
<script type="text/javascript"
	src="../js/bootstrap-datetimepicker.fr.js"></script>
<script type="text/javascript" src="../js/bootstrap-datetimepicker.js"></script>
<script type="text/javascript"
	src="../js/bootstrap-datetimepicker.zh-CN.js"></script>
</head>

<body>
	<div class="container">
		<div class="row">
			<div class="col-md-12">
				<ol class="breadcrumb">
					<li><a href="main.jsp">徐州工程学院失物招领平台</a></li>
					<li class="active">物品信息描述</li>
				</ol>
			</div>
			<div class="col-md-12">
				<form class="forborder form-horizontal" id="myform"
					onsubmit="return checkform()" enctype="multipart/form-data"
					name="myform" method="post">
					<!-- 填写类别 -->

					<!--物品描述-->
					<div class="form-group">
						<label for="itemcategory" class="col-sm-3 control-label">请选择你的物品类别(*)</label>
						<div class="col-sm-6">
							<select class="form-control" id="categotyappend"
								name="selectitem">
								<option value="0">--请选择你的物品类型--</option>

							</select>
						</div>
					</div>

					<!--如果选择了卡号-->
					<div class="form-group" style="display: none;" id="cardshow">
						<label for="itemcategory" class="col-sm-3 control-label">请输入你的证件号(*)</label>
						<div class="col-sm-6">
							<input type="idnumber" class="form-control" id="idcard"
								placeholder="请输入证件号" name="cardId">
						</div>
					</div>
					<!-- 物品别名-->
					<div class="form-group">
						<label for="inputdiyitem3" class="col-sm-3 control-label">请输入物品名称(*)</label>
						<div class="col-sm-6">
							<input type="phone" class="form-control" id="inputitemname"
								placeholder="你自己对物品的描述(不超过15个字)" name="itemsDescripton">
						</div>
					</div>
					<!-- 联系方式-->
					<div class="form-group">
						<label for="inputPhone3" class="col-sm-3 control-label">请输入联系方式(*)</label>
						<div class="col-sm-6">
							<input type="text" class="form-control" id="inputphone"
								placeholder="不填写将默认你详细信息里的联系方式" name="phone">
						</div>
					</div>

					<!--联系姓名-->
					<div class="form-group">
						<label for="inputName" class="col-sm-3 control-label">请输入联系姓名(*)</label>
						<div class="col-sm-6">
							<input type="text" class="form-control disabled" id="contactname"
								placeholder="联系姓名和匿名二选一" name="name">
						</div>
					</div>
					<!--是否匿名-->
					<div class="form-group">
						<label for="hidename" class="col-sm-3 control-label">是否匿名(*)</label>
						<div class="col-sm-6">
							<div class="radio">
								<label> <input type="radio" name="hide" id="hide1"
									value="hide1" checked> 匿名
								</label>
							</div>
							<div class="radio">
								<label> <input type="radio" name="hide" id="hide2"
									value="hide2" checked> 不匿名
								</label>
							</div>
						</div>
					</div>
					<!--暂存地点-->
					<div class="form-group" style="display: none;" id="temp">
						<label for="itemcategory" class="col-sm-3 control-label">请选择暂存地点</label>
						<div class="col-sm-6">
							<input class="span2" size="16" type="text" id="losingId" name="losingId">
						</div>
					</div>
					<!--时间-->
					<div class="form-group">
						<label for="inputtime" class="col-sm-3 control-label">时间</label>
						<div class="col-sm-6">
							<div class="input-append date" id="datetimepicker"
								data-date="12-02-2012" data-date-format="dd-mm-yyyy">
								<input class="span2" size="16" type="text" id="time" name="time">
								<span class="add-on"><i class="glyphicon glyphicon-time"></i></span>
							</div>
						</div>
					</div>
					<!--地点-->
					<div class="form-group">
						<label for="inputlocation" class="col-sm-3 control-label">地点</label>
						<div class="col-sm-6">
							<input type="text" class="form-control" id="inputlocation"
								placeholder="" name="itemlocation">
						</div>
					</div>
					<div class="form-group">
						<label for="inputEmail3" class="col-sm-3 control-label">图片</label>
						<div class="col-sm-9">
							<img id="picture" style="width: 500px; height: 300px" />
							<input type="file" name="picture" id="file" />
						</div>
					</div>
					<!--详细描述-->
					<div class="form-group">
						<label for="inputEmail3" class="col-sm-3 control-label">事件详情</label>
						<div class="col-sm-6">
							<script id="editor" type="text/plain"
								style="width:100%;height:500px;" name="detaildescription"></script>
						</div>
					</div>

					<div class="form-group">
						<div class="col-sm-6">
							<button class="btn btn-default" style="float: right;" id="put">提交</button>
						</div>
						<div class="col-sm-6">
							<button type="reset" class="btn btn-danger">重置</button>
						</div>
					</div>
				</form>

			</div>
		</div>

		<div></div>

		<!--
				固定在窗口的
			-->
		

		<script type="text/javascript">
				//实例化编辑器
				//建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
				var ue = UE.getEditor('editor');
				//时间控件初始化
				$('#datetimepicker').datetimepicker({
					format: "yyyy-MM-dd",
				});
			</script>
		<script type="text/javascript">
		var ue = UE.getEditor('editor');
			     $(function(){
			    	 function getUrlParam(name)
		        	  {
		        	  var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
		        	  var r = window.location.search.substr(1).match(reg);  //匹配目标参数
		        	  if (r!=null) return unescape(r[2]); return null; //返回参数值
		        	  } 
		        	  var id=getUrlParam("id");	 
			    	
			    	 
			    	 $("#textnote").hide();
			    	 $.ajax({
			    		 type:"post",
			    		 url:"../user/allcategory.action",
			    		 dataType:"json",
			    		 success:function(data){
			    			 for(var i=0;i<data.length;i++){
			    				 $("#categotyappend").append("<option value="+data[i].categoryID+">"+data[i].categoryName+"</option>");
			    			 }
			    			
			    		 }
			    	 });
			    	 $.ajax({
			    		 type:"post",
			    		 url:"../user/alllocation.action",
			    		 dataType:"json",
			    		 success:function(data){
			    			 for(var i=0;i<data.length;i++){
			    				 $("#templocation").append("<option value="+data[i].locid+">"+data[i].locationaddress+"</option>");
			    			 }
			    			
			    		 }
			    	 });
			    	 
			    	$("input:radio[name='hide']").click(function(){
			    		var hide= $("input:radio[name='hide']:checked").val();
			    		if(hide=='hide1'){
			    			$("#contactname").attr("readonly",true);
			    			$("#contactname").val("匿名");
			    		}else if(hide=='hide2'){
			    			$("#contactname").removeAttr("readonly");
			    			$("#contactname").val("");
			    		}
			    	});
			    	$("#typreg").change(function(){
			    		var type=$("#typreg").find("option:selected").val();
			    		if(type==2){
			    			$("#temp").show();
			    		}else{
			    			$("#temp").hide();
			    		}
			    	})
			    	
			    	$("#categotyappend").change(function(){
			    		var value=$("#categotyappend").find("option:selected").val();
			    		if(value==1||value==2||value==3||value==4){
			    			$("#cardshow").show();
			    		}else{
			    			$("#cardshow").hide();
			    		}
			    	});
			    	
			    	$.ajax({
			    		type:"post",
			    		url:"../user/losdetail.action?picid="+id,
			    		dataType:"json",
			    		success:function(data){
			    			if(data.cardid!=null){
		            			  $("#cardshow").show();
		            			  $("#idcard").val(data.cardid);
		            		  }
		            		  $("#inputitemname").val(data.itemsDescription);
		            		  $("#inputphone").val(data.phone);
		            		  $("#contactname").val(data.userName);
		            		  $("#time").val(data.losingTime);
		            		  $("#picture").attr("src","/pic/"+data.picture);
		            		  $("#inputlocation").val(data.itemLoaction);
		            		 $("#categotyappend").find("option[value="+data.categoryID+"]").attr("selected","true");
		            		 $("#losingId").val(id);
			    		}
		})
			    	
			     });
			     function checkform(){
			    	    var type=$("#typreg").find("option:selected").val();
			    		if(type==0){
			    			alert("请选择登记类别");
			    			return false;
			    		};	
			    		var category=$("#categotyappend").find("option:selected").val();
			    	    if(category==0){
			    	    	alert("请选择物品类别");
			    	    	return false;
			    	    }	    
			    	    var inputitemname=$("#inputitemname").val();
			    	    if(inputitemname.length>=15){
			    	    	alert("物品描述不能超过15个字符");
			    	    	return false;
			    	    }
			    	    var templocation=$("#templocation").find("option:selected").val();
			    	    if(templocation==0&&type==2){
			    	    	alert("请选择暂存地点");
			    	    	return false;
			    	    }
			    	    var file = $("#file").val();   
			    	    if(!/.(gif|jpg|jpeg|png|gif|jpg|png)$/.test(file)){   
	    	               alert("图片类型必须是.gif,jpeg,jpg,png中的一种");
	    	               return false;
			    	    }
			    	    //var para={"type":type,"category":category,"inputitemname":inputitemname,
			    	    //	"idcard":$("#idcard").val(),"inputphone":$("#inputphone").val()};
			    	    
			    	    $("#myform").attr("action","../user/updatelos.action");
			    	    return true;
			     }
			     
			     
			</script>
</body>

</html>